package org.jxc.web.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.team4.domain.Department;
import org.team4.service.DepartmentService;

import org.team4.web.action.GenericAction;


@Controller
@Scope("prototype")
public class ProductPriceAction extends GenericAction<Department> {

    private static final long serialVersionUID = -4867867482994497216L;

    @Autowired
    private DepartmentService departmentService;
    private List<Department> departmentList;
    private Department department;
    private String deptId;

    /**
     * 部门树
     * 
     * @return
     * @throws Exception
     */
    public String listTree() throws Exception {
        departmentList = departmentService.findAllDepartment();
        return SUCCESS;
    }

    public String listPagination() throws Exception {
        page = departmentService.listPagination(page, deptId);
        return SUCCESS;
    }

    /**
     * 预新建
     * 
     * @return
     * @throws Exception
     */
    public String toSave() throws Exception {
        departmentList = departmentService.findAllDepartment();
        return SUCCESS;
    }

    /**
     * 新建
     * 
     * @return
     * @throws Exception
     */
    public String save() throws Exception {
        departmentService.saveDepartment(department);
        return SUCCESS;
    }

    /**
     * 预修改
     * 
     * @return
     * @throws Exception
     */
    public String toUpdate() throws Exception {
        department = departmentService.findById(deptId);
        departmentList = departmentService.findDepartmentNotLike(department.getCode());
        return SUCCESS;
    }

    /**
     * 修改
     * 
     * @return
     * @throws Exception
     */
    public String update() throws Exception {
        departmentService.updateDepartment(department);
        return SUCCESS;
    }

    /**
     * 删除
     * 
     * @return
     * @throws Exception
     */
    public String delete() throws Exception {
        departmentService.deleteDepartment(idList);
        return SUCCESS;
    }

    public List<Department> getDepartmentList() {
        return departmentList;
    }

    public void setDepartmentList(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public String getDeptId() {
        return deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }
}